package com.joysuch.wwyt.workflow.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.mh.bean.ProcessNoticeSearchBean;
import com.joysuch.wwyt.workflow.entity.ProcessNoticeList;
import com.joysuch.wwyt.workflow.service.ProcessNoticeListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  流程通知
 * </p>
 *
 * @author jwk
 * @since 2021-07-20
 */
@RestController
@RequestMapping("/workflow/process-notice")
@Api(tags = "流程通知")
public class ProcessNoticeListController {

    @Autowired
    private ProcessNoticeListService processNoticeListService;


    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "保存或修改")
    @RequiresPermissions("workflow:process-notice:save")
    public ResultBean saveOrUpdate(@RequestBody ProcessNoticeList processNoticeList) {
        processNoticeListService.saveOrUpdate(processNoticeList);
        return ResultBean.defaultSuccessResult();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    @RequiresPermissions("workflow:process-notice:delete")
    public ResultBean delete(Long noticeId) {
        ProcessNoticeList point = new ProcessNoticeList();
        point.setDeleteFlag("1");
        point.setId(noticeId);
        processNoticeListService.updateById(point);
        return ResultBean.defaultSuccessResult();
    }

    @GetMapping("/list")
    @ApiOperation(value = "列表")
    public ResultBean list(@Validated ProcessNoticeSearchBean searchBean) {
        IPage<ProcessNoticeList> list = processNoticeListService.findListPaging(searchBean);
        return ResultBean.pageData(list.getRecords(), list.getTotal());
    }
}

